﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MillerApp.DataContract.Common;

namespace MillerApp.UserControls
{
    public partial class MaintainActionControl : UserControl
    {
        public MaintainActionControl()
        {
            InitializeComponent();
            this.Load += new EventHandler(MaintainActionControl_Load);
        }

        void MaintainActionControl_Load(object sender, EventArgs e)
        {
            if (this.ParentForm is EnitityFormBase)
            {
                EnitityFormBase form = this.ParentForm as EnitityFormBase;
                if (form.ActionTypeCode == Enums.ActionType.View)
                {
                    this.Visible = false;
                }
                else if (form.ActionTypeCode == Enums.ActionType.Modify || form.ActionTypeCode == Enums.ActionType.AddNew)
                {
                    this.btnDeleted.Visible = false;
                }
                else if (form.ActionTypeCode == Enums.ActionType.Deleted)
                {
                    this.btnSave.Visible = false;
                }
            }
        }

        public event DelegateMethod ActionMethod;

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ActionMethod != null)
            {
                ActionMethod();
            }
        }

        private void btnDeleted_Click(object sender, EventArgs e)
        {
            if (ActionMethod != null)
            {
                ActionMethod();
            }
        }
    }
}
